package com.yehebl.orm.dto;

import com.yehebl.orm.config.IConfig;
import com.yehebl.orm.enums.TableNameRule;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 解析类与表的信息
 * 
 * @author tzd
 *
 */
public class ClassInfo {


	private IConfig config;

	/**
	 * 对应类
	 */
	private Class<?> clazz;

	/**
	 * 表名
	 */
	private String tableName;


	/**
	 * 表名规则
	 */
	private TableNameRule tableNameRule;

	/**
	 * 实体字段对应表字段
	 */
	private Map<String, FieldInfo> fieldMap = new HashMap<>();

	/**
	 * 表字段对应表字段
	 */
	private Map<String, FieldInfo> tableFieldMap = new HashMap<>();

	/**
	 * 所有字段
	 */
	private Map<String, FieldInfo> allFieldMap = new HashMap<>();

	/**
	 * Id对象
	 */
	private List<FieldInfo> idFieldInfo = new ArrayList<>();

	public IConfig getConfig() {
		return config;
	}

	public void setConfig(IConfig config) {
		this.config = config;
	}

	public TableNameRule getTableNameRule() {
		return tableNameRule;
	}

	public void setTableNameRule(TableNameRule tableNameRule) {
		this.tableNameRule = tableNameRule;
	}

	public String getTableName() {
		if (tableNameRule!=null){
			return config.getTableRuleName(this.getTableNameRule(),tableName);
		}
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public Map<String, FieldInfo> getFieldMap() {
		return fieldMap;
	}

	public void setFieldMap(Map<String, FieldInfo> fieldMap) {
		this.fieldMap = fieldMap;
	}

	public Map<String, FieldInfo> getTableFieldMap() {
		return tableFieldMap;
	}

	public void setTableFieldMap(Map<String, FieldInfo> tableFieldMap) {
		this.tableFieldMap = tableFieldMap;
	}

	public Map<String, FieldInfo> getAllFieldMap() {
		return allFieldMap;
	}

	public void setAllFieldMap(Map<String, FieldInfo> allFieldMap) {
		this.allFieldMap = allFieldMap;
	}

	public List<FieldInfo> getIdFieldInfo() {
		return idFieldInfo;
	}

	public void setIdFieldInfo(List<FieldInfo> idFieldInfo) {
		this.idFieldInfo = idFieldInfo;
	}

	public Class<?> getClazz() {
		return clazz;
	}

	public void setClazz(Class<?> clazz) {
		this.clazz = clazz;
	}

}
